<?php 
if(isset($_REQUEST['hdn_staff_id_list'])){
	$v_list_staff_id = $_REQUEST['hdn_staff_id_list'];
}else{
	$v_list_staff_id = "";
}
$v_filter = "";
if(isset($_REQUEST['hdn_filter'])){
	$v_filter=_replace_bad_char(trim($_REQUEST['hdn_filter']));
}
$v_cate_filter= 0;
if(isset($_REQUEST['hdn_cate_filter'])){
	$v_cate_filter = intval($_REQUEST['hdn_cate_filter']);
}	
$v_url = "/list/recordtype/index.php?modal_dialog_mode=1" . "&hdn_recordtype_id=" . $v_recordtype_id . "&fuseaction=DISPLAY_SINGLE_RECORDTYPE" ;
// Kiem tra xem nguoi dang nhap hien thoi co quyen cap nhat hay khong?
if(!_check_permission_on_function($_SESSION['staff_id'], $_ISA_APP_CODE, _CONST_ONEGATE_RECORDTYPE_UPDATE)){?>
	<script>
		alert("<? echo _CONST_FUNCTION_PERMISSION_ERROR; ?>");
		if (_MODAL_DIALOG_MODE==1){
			window.location = "<? echo $v_url; ?>";
		}else{
			window.history.back();
		}	
	</script><?
}

$v_old_recordtype_id =  _replace_bad_char(trim($_REQUEST['hdn_item_id']));
$v_recordtype_id =  _replace_bad_char(trim($_REQUEST['txt_code']));
$v_name =  _replace_bad_char($_REQUEST['txt_name']);
$v_order = intval($_REQUEST['txt_order']);
if ($v_order==""){
	$v_order = NULL;
}
$v_status = intval($_REQUEST['hdn_recordtype_status']);
$v_is_view_on_net = intval($_REQUEST['hdn_view_on_net']);
$v_is_register_on_net = intval($_REQUEST['hdn_register_on_net']);
$v_submit_to_leader = intval($_REQUEST['hdn_submit_to_leader']);
$v_transfer_to_senior = intval($_REQUEST['hdn_transfer_to_senior']);
$v_doc_with_multi_object = intval($_REQUEST['hdn_doc_with_multi_object']);
$v_move_to_leader = intval($_REQUEST['hdn_move_to_leader']);
$v_handover_to_customer = intval($_REQUEST['hdn_handover_to_customer']);
$v_manage_on_post_license = intval($_REQUEST['hdn_manage_on_post_license']);
//echo 'v_is_view_on_net'.$v_is_view_on_net; exit;
$v_process_date = intval($_REQUEST['txt_process_date']);
$v_first_time_fee = intval($_REQUEST['txt_first_time_fee']);
$v_second_time_fee = intval($_REQUEST['txt_second_time_fee']);
$v_begin_recod_code = intval($_REQUEST['txt_begin_recod_code']);
$v_begin_license_number = intval($_REQUEST['txt_begin_license_number']);

$v_handle_agency_id =0;
if(isset($_REQUEST['hdn_handle_agency_id'])){
	$v_handle_agency_id = intval($_REQUEST['hdn_handle_agency_id']);
} 
$v_receiver_id =0;
if(isset($_REQUEST['hdn_receiver_id'])){
	$v_receiver_id= intval($_REQUEST['hdn_receiver_id']);
} 
$v_handler_id =0;
if(isset($_REQUEST['hdn_handler_id'])){
	$v_handler_id= intval($_REQUEST['hdn_handler_id']);
}
//Lay danh sach id cua lanh dao duyet lan dau
$v_handle_leader_first_time_id =0;
if(isset($_REQUEST['hdn_handle_leader_first_time_id'])){
	$v_handle_leader_first_time_id = $_REQUEST['hdn_handle_leader_first_time_id'];
}
if(is_null($v_handle_leader_first_time_id) || ($v_handle_leader_first_time_id=="")){
	$v_handle_leader_first_time_id =0;
}
//Lay danh sach id cua lanh dao duyet lan cuoi
$v_approve_leader_id_list =0;
if(isset($_REQUEST['hdn_approve_leader_list_id'])){
	$v_approve_leader_id_list= $_REQUEST['hdn_approve_leader_list_id'];
}
$v_handle_leader_id =0;
if(isset($_REQUEST['hdn_handle_leader_id'])){
	$v_handle_leader_id= intval($_REQUEST['hdn_handle_leader_id']);
} 
//echo 'v_handle_leader_id'.$v_handle_leader_id.'<br>';
$v_result_doc_type= trim($_REQUEST['sel_result_doc_type']);

$v_system_id = "";
if(isset($_REQUEST['hdn_system_id'])){
	$v_system_id= trim($_REQUEST['hdn_system_id']);
}
$v_handler_list_id = "";
if(isset($_REQUEST['hdn_handler_list_id'])){
	$v_handler_list_id= trim($_REQUEST['hdn_handler_list_id']);
} 


//echo $v_handler_list_id;
//exit;
$v_save_and_add_new = intval($_REQUEST['hdn_save_and_add_new']);
$v_url = "/list/recordtype/index.php?modal_dialog_mode=1" . "&hdn_recordtype_id=" . $v_recordtype_id . "&fuseaction=DISPLAY_SINGLE_RECORDTYPE" ;

$v_cate_id = 0;
if(isset($_REQUEST['hdn_cate'])){
	$v_cate_id= intval($_REQUEST['hdn_cate']);
} 
echo a
if(_is_sqlserver()){
	$sql = "Exec ONEGATE_RecordtypeUpdate " ;
	$sql = $sql . "'". $v_recordtype_id."'";
	$sql = $sql . ",'". $v_old_recordtype_id."'";
	$sql = $sql . ",'". $v_name."'";
	$sql = $sql . ",". $v_order;
	$sql = $sql . ",". $v_status;
	$sql = $sql . ",". $v_process_date;
	$sql = $sql . ",". $v_first_time_fee;
	$sql = $sql . ",". $v_second_time_fee ;
	$sql = $sql . ",". $v_begin_recod_code;
	$sql = $sql . ",". $v_begin_license_number;
	$sql = $sql . ",'". $v_result_doc_type."'";
	$sql = $sql . ",". $v_cate_id;
	$sql = $sql . ",". $v_handle_agency_id;
	$sql = $sql . ",'". $v_list_staff_id."'";    
	$sql = $sql . ",'". $v_handler_list_id."'";
	//$sql = $sql . ",". $v_approve_leader_id;
	$sql = $sql . ",'". $v_approve_leader_id_list;	
	$sql = $sql . "',". $v_handle_leader_id;
	$sql = $sql . ",'". $v_system_id."'";
	$sql = $sql . ",". $v_is_view_on_net;
	$sql = $sql . ",". $v_is_register_on_net;
	$sql = $sql . ",". $v_submit_to_leader;
	$sql = $sql . ",". $v_transfer_to_senior;
	$sql = $sql . ",". $v_doc_with_multi_object;	
	$sql = $sql . ",". $v_handover_to_customer;
	$sql = $sql . ",". $v_manage_on_post_license ;	
	$sql = $sql . ",". $v_move_to_leader ;
	$sql = $sql . ",". $v_handle_leader_first_time_id ;
	//echo $sql.'<br>'; exit;
	
		
	$ado_conn->SetFetchMode(ADODB_FETCH_ASSOC);
	$rs = $ado_conn->GetRow($sql); 
	
	$v_error = _replace_bad_char(trim($rs['RET_ERROR']));
}

if (!is_null($v_error) and $v_error<>""){?>
	<script>
		alert("<?php echo $v_error; ?>");
		if (_MODAL_DIALOG_MODE==1){
			window.location = "<?php echo $v_url; ?>";
		}else{
			window.history.back();
		}	
	</script><?php
	exit;
}
sleep(0);
?>
<form action="index.php" method="post" name="f_back">
	<input type="hidden" name="fuseaction" value="DISPLAY_ALL_RECORDTYPE">
	<input type="hidden" name="hdn_filter" value="<?php echo $v_filter; ?>">
	<input type="hidden" name="hdn_item_id" value="<?php echo $v_old_recordtype_id;?>">
	<input type="hidden" name="hdn_cate_filter" value="<?php echo $v_cate_filter; ?>">
</form>
<Script language="javascript">
	document.forms(0).submit();	
</Script>
